package im.elephas.androfan.common.widget;

import im.elephas.androfan.activity.AndroFanActivity;
import im.elephas.androfan.activity.PersonalInfoActivity;
import im.elephas.androfan.activity.SendMessageActivity;
import im.elephas.androfan.fanfouapi.items.StatusItem;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup;

public class FavoriteWidget extends StatusWidget {

	public FavoriteWidget(ViewGroup parentView, AndroFanActivity mActivity) {
		super(parentView, mActivity);
	}

	public FavoriteWidget(ViewGroup parentView, AndroFanActivity mActivity,
			StatusItem si) {
		super(parentView, mActivity, si);
	}

	@Override
	protected void showDialog() {
		Builder dialog = new AlertDialog.Builder(getActivity());
		String[] sel = { "删除", "回复", "私信", "查看资料" };
		dialog.setTitle("对@" + getStatusItem().getUser().getScreenName());
		dialog.setItems(sel, new Dialog.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				Intent i;
				Bundle b;
				switch (which) {
				case 0:
					getApiCaller().destroyFavoriteStatus(getStatusItem());
					setInvisible();		
					break;
				case 1:
					i = new Intent(getActivity(), SendMessageActivity.class);
					b = new Bundle();
					b.putBoolean("isreply", true);
					b.putString("atname", getStatusItem().getUser().getName());
					b.putString("replyid", getStatusItem().getUser().getId());
					i.putExtras(b);
					getActivity().startActivityForResult(i, 0);
					break;
				case 2:
				case 3:
					i = new Intent(getActivity(), PersonalInfoActivity.class);
					b = new Bundle();
					b.putSerializable("item", statusItem.getUser());
					i.putExtras(b);
					getActivity().startActivityForResult(i, 0);
					break;
				default:
					break;
				}
			}
		});
		dialog.show();
	}

}
